﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace welding
{
    public class cvs
    {

        public enum ErrorCode
        {
            noError,
            productNotExist,
            processNotExist,
            deviceNotExist,
            stationNotExist,
            processTooShort,
            stationNotInProcess


        }

        public enum AccessRight
        {
            Operator = 3,
            Technician = 5,
            Admin = 8
        }


        //PLC related

        public static int db = 101;



        #region File Name & Path

        public class DP
        {
            //存放数据的目录，所有的数据和参数都存放在这个目录中
            public const string DATA_DIRECTORY = @"D:\APPDATA\";

            public const string SQL_COMMAND_DIRECTORY = @"D:\APPDATA\SQLCOMMAND\";

            public const string LOG_DIRECTORY = @"D:\DEBUGDATAFILES\";

            //系统配置文件名
            public const string SYSTEM_CONFIG_FILE = @"PARAMETERS.XML";

        }

        #endregion


        #region Communication Protocol

        public class COMM
        {
            // PLC TO PC
            public const int MFG_FINISHED = 100;        //加工完成

            // PC T0 PLC
            public const int DATA_SAVED = 101;

            public const int READY = 200;               //可以加工

        }

        public class MODBUS
        {
            public const int STEP_IDLE = 0;                 // MES 空闲，在发送验证之前
            //public const int STEP_BARCODE_OK = 100;         // MES 条码验证成功
            public const int STEP_SENT_RESET = 200;         // MES 已经发送复位信号
            //public const int STEP_RESET = 300;              // 电测设备复位成功信号
            public const int STEP_SENT_START = 400;         // MES 已经发送启动检测信号
            public const int STEP_TESTING = 500;            // 正在检测
            public const int STEP_TEST_OVER = 600;          // 检测完成信号
            //public const int STEP_DATA_SAVED = 700;         // MES 数据保存完成
        }
        #endregion

        #region FINAL RESULT

        public class FINAL_RESULT
        {
            public const int BYPASS = 0;
            public const int VALID = 100;
            public const int INVALID = 101;
        }

        #endregion

        #region 设备状态信息 / 命令
        public class DEVICE_STATE
        {
            public const int NORMAL = 0; //正常状态
            public const int SUSPENDED = 11; //停机状态
        }

        public class DEVICE_COMMAND
        {
            public const int BACK_TO_NORMAL = 0; //使回复正常，由客户端发送
            public const int TO_SUSPEND_DEVICE = 11; //使停机，由客户端发送
            public const int GET_DEVICE_STATE = 21; //获取设备状态，由客户端发送
            public const int GET_DEVICE_STATE_REPLY = 22; //由UCOM端发送设备状态至客户端
            public const int REPORT_YIELD_SWITCH_TO_MANUAL = 100; //报产转为手动状态，由客户端发送
            public const int REPORT_YIELD_SWITCH_TO_AUTO = 110; //报产转为自动状态，由客户端发送
        }
        #endregion

        #region 报产信息
        /// <summary>
        /// 报产方式
        /// </summary>
        public class REPORT_YIELD_TYPE
        {
            public const int AUTO = 1; //自动报产
            public const int MANUAL = 2; //手动报产
        }
        /// <summary>
        /// 报产状态，是否完成报产
        /// </summary>
        public class REPORT_YIELD_STATUS
        {
            public const int MANUAL = 2;        //手动报产
            public const int DONE = 1;          //完成报产
            public const int TO_BE_DONE = 0;    //未完成报产
        }
        #endregion

    }
}
